import Vue from 'vue';
import $web3js from './web3.js';
import $erc20Token from './erc20Token/index.js';
import $dmcMining from './dmcMining/index.js';
import $ifil721 from './ifil721/index.js';
import $ifilAbs from './ifilAbs/index.js';
import $ifilJoint from './ifilJoint/index.js';
import $ifilJointU from './ifilJointU/index.js';
import $ifilMining from './ifilMining/index.js';
import $ifilNftTrade from './ifilNftTrade/index.js';
import $ifilToken from './ifilToken/index.js';
import $ifilVendor from './ifilVendor/index.js';
import $usdt from './usdt/index.js';
import $peTimeLock from './peTimeLock/index.js';
import $swapMining from './swapMining/index.js';
import $IMdexPair from './IMdexPair/index.js';



let defaultInviteCode = "DMEX";

const getDefaultInviteCode = () => {
  return defaultInviteCode;
}

const getInviterCode = () => {
  let $key = 'inviter_code';
  return Vue.prototype.$storage.get($key);
}

const setInviterCode = (inviteCode) => {
  let $key = 'inviter_code';
  return Vue.prototype.$storage.set($key, inviteCode);
}

const checkNotSupportWeb3jsV1 = (error) => {
  return String(error).startsWith(
    "Error: The current provider doesn't support subscriptions:"
  ) ||
    String(error).startsWith(
      "Error: eth_subscribe is not supported"
    )
}

export default {
  ...$web3js,
  // erc20
  ...$erc20Token,
  ...$dmcMining,
  // ifil 721 Contract
  ...$ifil721,
  // abs contract
  ...$ifilAbs,
  // joint contract
  ...$ifilJoint,
  ...$ifilJointU,
  // ifil miner contract
  ...$ifilMining,
  // nft trade contract
  ...$ifilNftTrade,
  // ifil token contract
  ...$ifilToken,
  // vendor contract
  ...$ifilVendor,
  // usdt contract
  ...$usdt,
  ...$peTimeLock,
  ...$swapMining,
  ...$IMdexPair,
  // other setting
  getDefaultInviteCode,
  getInviterCode,
  setInviterCode,
  checkNotSupportWeb3jsV1,
}
